home *** CD-ROM | disk | FTP | other *** search
Wrap
function ISRILxul() { this.dPrefix = 'isRitL-'; this.sPrompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); this.curPage = 1; this.keyStates = new Array(); this.wType = 'normal'; this.sidebarMarkWait = 2.25 * 1000; } ISRILxul.prototype = { _init : function(wType) { this.wType = !wType ? this.wType : wType; this.window = window; this.later = this.bip('later'); this.mark1 = this.bip('mark1'); this.mark2 = this.bip('mark2'); this.And = this.bip('markAnd'); this.AndLinks = this.bip('markAndLinks'); this.markAndMore = this.bip('markAndMore'); this.AndMoreList = this.bip('markAndMoreItems'); this.List = this.bip('List'); this.ListContent = this.bip('ListContent'); this.ListMsg = this.bip('Msg'); this.ListBtn = this.bip('ReadSomething'); this.Sort = this.bip('ListSort'); this.Filter = this.bip('ListFilter'); this.Page = this.bip('ListPage'); this.PageItems = this.bip('ListPageItems'); this.Previous = this.bip('ListPrevious'); this.Next = this.bip('ListNext'); if (this.wType == 'normal') { //Move context items into place ISRILxul.bi('contentAreaContextMenu').insertBefore(ISRILxul.bi('context-isRitL-ReadLaterLink'), ISRILxul.bi('context-bookmarklink')); ISRILxul.bi('contentAreaContextMenu').insertBefore(ISRILxul.bi('context-isRitL-ReadLater'), ISRILxul.bi('context-bookmarkpage')); ISRILxul.bi('context_bookmarkAllTabs').parentNode.insertBefore(ISRILxul.bi('context-isRitL-SaveAllTabs'), ISRILxul.bi('context_bookmarkAllTabs')); ISRILxul.bi("contentAreaContextMenu").addEventListener("popupshowing", ISRILxul.contextPopupShowing, false); } }, _init_finish : function() { ISRILxul.ShowCount(); ISRILxul.UseClickToSaveStatusBar(); if ( ISRILxul.bip('ReadSomething')) { ISRILxul.bip('ReadSomething').onclick = ISRILxul.SetButtonTarget; } }, bi : function(id) { return ( (this.doc)?(this.doc):(document) ).getElementById(id); }, bip : function(id) { return this.bi(this.dPrefix + id); }, changeDoc : function(doc, win) { ISRILxul.doc = doc; win.addEventListener("unload", function() { ISRILxul.doc = null; }, false); }, // --- // contextPopupShowing : function() { if (ISRILprefs.prefB('context-menu')) { if ( (gContextMenu.onSaveableLink || ( gContextMenu.inDirList && gContextMenu.onLink )) ) { gContextMenu.showItem("context-isRitL-ReadLaterLink", true); gContextMenu.showItem("context-isRitL-ReadLater", false); } else if (gContextMenu.isTextSelected) { gContextMenu.showItem("context-isRitL-ReadLaterLink", false); gContextMenu.showItem("context-isRitL-ReadLater", false); } else { gContextMenu.showItem("context-isRitL-ReadLaterLink", false); gContextMenu.showItem("context-isRitL-ReadLater", true); } } else { gContextMenu.showItem("context-isRitL-ReadLaterLink", false); gContextMenu.showItem("context-isRitL-ReadLater", false); } }, // --- // IconHover : function() { ISRILxul.mark1.className = ISRILxul.dPrefix + 'hover'; ISRILxul.mark2.className = ISRILxul.dPrefix + 'hover'; }, IconHoverOff : function() { ISRILxul.mark1.className = ''; ISRILxul.mark2.className = ''; }, // --- // SetBtn : function(t) { var l; var m1; var m2; switch(t) { case(1): l=false; m1=true; m2=true; ISRIL.lastURL = ISRIL.url(); break; case(2): l=true; m1=false; m2=false; if (ISRIL.url() != ISRIL.lastURL) { ISRIL.autoMarkTO = setTimeout('ISRIL.autoMark()', ISRIL.autoMarkWait * 1000); } break; default: l=true; m1=true; m2=true; } if (ISRILxul.bip('later')) { ISRILxul.bip('later').hidden = l; } if (ISRILxul.bip('mark1')) { ISRILxul.bip('mark1').hidden = m1; } if (ISRILxul.bip('mark2')) { ISRILxul.bip('mark2').hidden = m2; } }, MarkAsReadAnd : function() { ISRILxul.And.setAttribute('hidden', false); ISRILxul.And.openPopup(ISRILxul.mark2, "after_end", -1, -1); ISRILxul.And.setAttribute('forcestyle', ISRILprefs.pref('force-styles')); ISRILxul.ClearMenu( ISRILxul.AndLinks ); ISRILxul.ClearMenu( ISRILxul.AndMoreList ); prefsites = ISRILprefs.pref('sites').split(','); prefsites.shift(); for(var i=0; i<prefsites.length; i++) { var newLabel = document.createElement('label'); newLabel.className = 'text-link'; newLabel.setAttribute('onclick', 'ISRIL.bookmark('+prefsites[i]+'); ISRIL.MarkAsRead(null, null, "'+prefsites[i]+'"); ISRILxul.closeAnd();'); newLabel.setAttribute('value', ISRIL.l('addTo') + ' ' + ISRIL_sites[ prefsites[i] ][0]); ISRILxul.AndLinks.appendChild( newLabel ); } for(i in ISRIL_sites) { var newItem = document.createElement('menuitem'); newItem.setAttribute('label', ISRIL_sites[ i ][0]); newItem.setAttribute('i', i); ISRILxul.AndMoreList.appendChild( newItem ); } }, closeAnd : function() { ISRILxul.And.setAttribute('hidden', true); }, ClearMenu : function(menu, cls) { for(var i=menu.childNodes.length - 1; i >= 0; i--) { if (!cls || (cls && menu.childNodes[i].className == cls)) { menu.removeChild(menu.childNodes.item(i)); } } }, ListStatus : function() { return (ISRILxul.window.ISRILxul.bi('sidebar').contentWindow.location.href == "chrome://isreaditlater/content/isreaditlaterlist.xul" || (ISRILxul.List.state!='closed' && ISRILxul.List.state!='hiding')); }, ToggleReadingList : function() { if ( ISRILxul.justClosed ) { return false; } ( (ISRILxul.List.state=='closed' || ISRILxul.List.state=='hiding') ? (ISRILxul.OpenReadingList()):(ISRILxul.CloseReadingList()) ); }, OpenReadingList : function(forceOpen) { ISRILxul.List.className = ''; if (ISRILxul.List.tagName == 'panel' && ISRILprefs.pref('list-place') == 'btn') { ISRILxul.List.setAttribute('hidden', false); ISRILxul.List.openPopup( ((ISRILxul.bip('ReadSomething'))?(ISRILxul.bip('ReadSomething')):(ISRILxul.bi('urlbar-container'))) , "after_end", -1, -1); ISRILxul.bip('ListGrid').setAttribute('flex', (ISRILprefs.pref('list-type') == 'scroll') ? 2 : 0); } else if (ISRILxul.wType == 'normal') { toggleSidebar('isRitL-sidebarlist', forceOpen); if ( ISRILxul.getSidebarWidth() < 300) { ISRILxul.setSidebarWidth(300) } return true; } ISRILxul.List.className += (ISRILprefs.pref('list-view') == 'cond') ? ' isRitL-cond' : ''; ISRILxul.List.className += (ISRILprefs.pref('list-type') == 'scroll') ? ' isRitL-scroll' : ''; ISRILxul.List.setAttribute('forcestyle', ISRILprefs.pref('force-styles')); // -- Default Options -- // sortOpts = {11:0,12:1,1:2,5:3,pr:4}; ISRILxul.Sort.selectedIndex = sortOpts[ ISRILprefs.pref('default-sort') ]; ISRILxul.Filter.value = ISRILglobals.filter; // -- Output List -- // ISRILxul.FillList(); ISRILxul.bip('RL-FeedLink').hidden = ( (ISRILprefs.prefB('feed')) ? (false):(true) ); ISRILxul.bip('RL-Sync').hidden = ( (ISRILprefs.prefB('sync')) ? (false):(true) ); ISRILxul.bip('RL-SetupSync').hidden = ( (ISRILprefs.prefB('sync')) ? (true):(false) ); // -- Page Counter -- // ISRILxul.updatePageCounter(); // --- Detecting Ctrl/Shift/Command Click --- // if (navigator.platform != 'Win32') { window.addEventListener("keydown", ISRILxul.KeyDown, false); window.addEventListener("keyup", ISRILxul.KeyUp, false); ISRILxul.keyStates = new Array(); } }, updatePageCounter : function() { ISRILxul.UpdateCurrentPage(); ISRILxul.fillSelect( ISRILxul.bip('ListPage') , 1, ISRILxul.totalPages, ISRILxul.curPage); }, UpdateCurrentPage : function() { ISRILxul.totalPages = Math.ceil(ISRILglobals.ListFilteredSize/ISRILxul.PerPage()); ISRILxul.curPage = ISRILxul.curPage < ISRILxul.totalPages ? ISRILxul.curPage : ISRILxul.totalPages; ISRILxul.curPage = ISRILxul.curPage > 0 ? ISRILxul.curPage : 1; return ISRILxul.curPage; }, PerPage : function() { return ISRILprefs.pref('list-page') * 1 >= 4 ? ISRILprefs.pref('list-page') : 4; }, setDefaultSort : function() { ISRILprefs.setPref('default-sort', ISRILxul.Sort.selectedItem.getAttribute('value')); }, FillList : function(reuse, Refresh) { if (ISRILglobals.listShowErrorOnOpen) { ISRILglobals.listShowErrorOnOpen.onCancel = ISRILxul.FillList; return ISRILxul.ListErrorSet(true, ISRILglobals.listShowErrorOnOpen); } if (Refresh) { ISRILxul.curPage = 1; ISRILxul.bip('ListPage').selectedIndex = 0; } //Additional Sorting var sort = ISRILxul.bip('ListSort') ? ISRILxul.bip('ListSort').selectedItem.getAttribute('value') : false; switch( sort ) { case('pr'): return ISRILpr.start(); break; default: ISRILpr.xul.MsgPostRankAsk(false); } ISRILglobals.filter = ISRILxul.bip('ListFilter').value; ISRILxul.PopulateList( ISRIL.GetList( sort, ISRILxul.bip('ListFilter').value, ((!reuse)?(false):(true)) ) ); }, PopulateList : function( l ) { ISRILxul.ClearMenu(ISRILxul.ListContent); ISRILxul.ShowJustList(); ISRILxul.UpdateCurrentPage(); if (ISRILprefs.pref('list-type')=='pages') { perPage = ISRILxul.PerPage(); start = (ISRILxul.curPage-1) * perPage; end = start + perPage * 1; } else { start = 0; end = ISRILglobals.ListFilteredSize; } //alert( start + ' | ' + end) var daysAgo = (ISRILprefs.pref('list-view')=='cond')?( ISRIL.l('daysAgoShort') ):( ISRIL.l('daysAgo') ); d = new Date(); ISRILxul.totalList = 0; for(i in l) { if (ISRILxul.totalList >= start && ISRILxul.totalList < end) { days = Math.round( (d.getTime() - l[i].dateAdded/1000) / 1000 / 60 / 60 / 24); nsURI = ISRIL.uri(l[i].uri); if (nsURI.scheme != 'about') { rowClass = ISRILxul.dPrefix+'ListRow '; rowClass += ( (ISRIL.listDrops[l[i].itemId])?(ISRILxul.dPrefix+'dim'):('') ); //If pending to be marked as read rowClass += ( (!navigator.onLine && !ISRILoffline.getF(l[i].itemId).exists())?(ISRILxul.dPrefix+'notoffline'):('') ); //If offline and item is not saved for offline viewing domain = nsURI.host.replace('www.',''); // -- Create Row -- // row = ISRILxul.createNode('row', { id : ISRILxul.dPrefix+'Item_'+l[i].itemId, align : 'center', class : rowClass, style : "background-image:url('"+ISRIL.sIcon.getFaviconImageForPage(nsURI).spec+"')" } ); //Title - Domain colT = ISRILxul.createNode('vbox', {flex:2}); Title = ISRILxul.createNode('label', { crop : 'end', value : (l[i].title.length > 0)?l[i].title:nsURI.spec, tooltiptext : l[i].title, class : ISRILxul.dPrefix+'ListItem', uri : l[i].uri, context : ISRILxul.dPrefix+"list-context" } ); Title.onclick = ISRILxul.ListItemClick; Title.onmouseover = ISRILxul.ListItemInStatusBar; Domain = ISRILxul.createNode('label', { crop : 'end', value : domain, class : 'isRitL-ListDomain', uri : 'http://'+domain, onclick : "ISRIL.GoTo('"+domain+"');ISRILxul.CloseReadingList();" } ); Domain.onmouseover = ISRILxul.ListItemInStatusBar; //List Mark Mark = ISRILxul.createNode('label', { value : '', class : 'isRitL-ListMark', tooltiptext : ISRIL.l('MarkAsRead'), onclick : "ISRILxul.MarkAsReadItem('"+l[i].itemId+"', this);" } ); if ( l[i].postrank) { //Postrank Info = ISRILxul.createNode('label', { align : 'center', value : l[i].postrank, style : 'background-color:'+l[i].postrank_color, class : ISRILxul.dPrefix+'PostRank' } ); Info.onclick = function() { ISRIL.GoTo('http://postrank.com', null, null, 'http://readitlaterlist.com'); } } else { //Age Info = ISRILxul.createNode('label', { align : 'center', value : (days>0) ? (days + ' ' + daysAgo) : ISRIL.l('today') , class : ISRILxul.dPrefix+'ListAge' } ); } row.appendChild(colT); colT.appendChild(Title); colT.appendChild(Domain); row.appendChild(Mark); row.appendChild(Info); ISRILxul.ListContent.appendChild(row); } } ISRILxul.totalList++; } ISRILxul.updatePageCounter(); ISRILxul.Previous.className = ((ISRILxul.curPage == 1)?('isRitL-dim'):('text-link')); ISRILxul.Next.className = ((ISRILxul.TotalPages() == 0 || ISRILxul.curPage == ISRILxul.TotalPages())?('isRitL-dim'):('text-link')); ISRILxul.ShowList(); }, ListItemInStatusBar : function(e) { ISRILxul.window.ISRILxul.bi('statusbar-display').label = this.getAttribute('uri'); }, ListItemClick : function(e) { var click = ISRILxul.ClickTarget(e, 'open'); if (click.targ) { ISRIL.GoTo(this.getAttribute('uri'), false, click.targ); if (click.targ != 'tab') { ISRILxul.CloseReadingList(); } } }, SetButtonTarget : function(e) { ISRILxul.ButtonTarget = ISRILxul.ClickTarget(e, 'open'); if (ISRILxul.ButtonTarget.which == 2) { ISRIL.Read(); } }, ClickTarget : function(e, defaultPref) { var targ; if (e.which != 3) { if (e.which == 1) { if (e.ctrlKey || ISRILxul.keyStates[224]) {//224 targ = 'tab'; ISRILxul.keyStates[ 17 ] = false; //FF doesn't run keyup event when clicking } else if (e.shiftKey || ISRILxul.keyStates[16]) { targ = 'window'; ISRILxul.keyStates[ 16 ] = false; //FF doesn't run keyup event when clicking } else if (defaultPref) { targ = ISRILprefs.pref(defaultPref); } } else if (e.which == 2) { targ = 'tab'; } } return {targ:targ,which:e.which}; }, ShowCount : function(allWindows) { if (allWindows) { //Cycle through windows to update var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var enumerator = wm.getEnumerator('navigator:browser'); while(enumerator.hasMoreElements()) { var win = enumerator.getNext(); if (win.ISRILxul.bip('ReadSomething')) { ISRILxul.ShowCountToggle( win.ISRILxul.bip('ReadSomething') ); } } } else if (ISRILxul.bip('ReadSomething')) { ISRILxul.ShowCountToggle( ISRILxul.bip('ReadSomething') ); } }, ShowCountToggle : function( obj ) { if (obj) { obj.className = ( (ISRILprefs.prefB('show-count')) ? ('isRitL-showCount'):('') ); } }, UpdateUnreadCounter : function() { if (ISRILxul.bip('ReadSomething')) { ISRILxul.bip('ReadSomething').setAttribute('unread', ISRILglobals.ListSize); } }, UpdateViews : function() { //If sidebar is open, reload list to show changes that we are about to send if (ISRILxul.bi("sidebar") && ISRILxul.bi("sidebar").contentWindow.location.href == "chrome://isreaditlater/content/isreaditlaterlist.xul") { ISRILxul.bi("sidebar").contentWindow.ISRILxul.FillList(true, true, true); } }, KeyDown : function(e) { ISRILxul.keyStates[ e.keyCode ] = true; }, KeyUp : function(e) { ISRILxul.keyStates[ e.keyCode ] = false; }, ListItemContextSet : function() { ISRILxul.bip('item-tab').setAttribute('uri', document.popupNode.getAttribute('uri') ); ISRILxul.bip('item-window').setAttribute('uri', document.popupNode.getAttribute('uri') ); }, ListItemContextClick : function(obj, targ) { ISRIL.GoTo(obj.getAttribute('uri'), false, targ); ISRILxul.CloseReadingList(); }, CloseReadingList : function() { if (ISRILxul.List.tagName == 'panel') { ISRILxul.List.hidePopup(); } if (navigator.platform != 'Win32') { window.removeEventListener("keydown", ISRILxul.KeyDown, false); window.removeEventListener("keyup", ISRILxul.KeyUp, false); } }, ListClosed : function() { var itemsRead = false; ISRILxul.RunListDrops(); if (itemsRead) { ISRILxul.curPage = 1; //clear page user is on } ISRILxul.justClosed = true; ISRILxul.justClosedTO = setTimeout('ISRILxul.justClosed=false',100); }, RunListDrops : function(hideItems) { ISRIL._func = ISRILxul.RunListDropsBatch; ISRIL._args = arguments; ISRIL.sBookmarks.runInBatchMode(ISRIL, null); }, RunListDropsBatch : function(hideItems) { for(id in ISRIL.listDrops) { if (ISRIL.listDrops[id]) { ISRIL.MarkAsRead( id, true ); itemsRead = true; if (hideItems && ISRILxul.bip('Item_'+id)) { ISRILxul.bip('Item_'+id).hidden = true; } } } ISRIL.listDrops = new Array(); //clear items to remove }, // -- // SidebarEvent : function() { if (ISRILxul.bi('sidebar').contentWindow.location.href == "chrome://isreaditlater/content/isreaditlaterlist.xul") { ISRILxul.RunListDrops(); } }, // --- // ShowList : function() { if (ISRILglobals.ListSize == 0) { ISRILxul.bip('Empty').hidden = false; ISRILxul.bip('ListContent').hidden = true; ISRILxul.bip('ListFooter').hidden = true; ISRILxul.bip('ListOpts').hidden = true; ISRILxul.bip('show_hotkey_toggle').value = '(' + ISRIL.l('shortcut') + ': '+ISRIL.hotkeyText('toggle')+')'; ISRILxul.bip('show_hotkey_click_mode').value = '(' + ISRIL.l('shortcut') + ': '+ISRIL.hotkeyText('click_mode')+')'; } else { if (ISRILglobals.ListFilteredSize == 0 && !ISRILxul.bip('nofiltermatch')) { var node = ISRILxul.createNode('label', {id:'isRitL-nofiltermatch', align:'center',style:'text-align:center'}); ISRILxul.ListContent.appendChild( node ); node.textContent = ISRIL.l('NoFilterMatch'); } ISRILxul.bip('Empty').hidden = true; ISRILxul.bip('ListContent').hidden = false; ISRILxul.bip('ListFooter').hidden = false; ISRILxul.bip('ListOpts').hidden = false; } }, ShowJustList : function() { ISRILxul.ListMsgSet(false); ISRILxul.ListErrorSet(false); ISRILxul.ListNotifySet('Sync', false); ISRILglobals.ViewedError = true; }, ListNotifySet : function(id, status, noTO) { this.bip('Notify-'+id).hidden = !status; if (!noTO && status) { clearTimeout(this.notifyTO); this.notifyTO = setTimeout('ISRILxul.ListNotifySet(\'' + id + '\', false)', 6500); } }, ListMsgSet : function(show, lId) { if (show) { ISRILxul.ListErrorSet(false); this.ListContent.hidden = true; this.ListMsg.hidden = false; this.bip('Error').hidden = true; this.bip('MsgTxt').value = ISRIL.l(lId) + '...'; } else { this.ListContent.hidden = false; this.ListMsg.hidden = true; } }, MsgPostRankAsk : function(show) { if (show) { this.bip('ListGrid').hidden = true; this.bip('ListMsg-pr').hidden = false; } else { this.bip('ListGrid').hidden = false; this.bip('ListMsg-pr').hidden = true; } }, ListErrorSet : function(show, a) { if (show) { if (this.ListStatus()) { this.ListMsgSet(false); this.ListContent.hidden = true; this.bip('Empty').hidden = true; this.bip('ListFooter').hidden = a.hideAll; this.bip('List-Top').hidden = a.hideAll; this.bip('Error').hidden = false; this.bip('ErrorTxt').firstChild.nodeValue = a.txt; if (a.txt2) { this.bip('ErrorTxt-2').firstChild.nodeValue = a.txt2; } else { this.bip('ErrorTxt-2').hidden = true; } this.bip('ErrorBtn').label = a.buttonTxt?a.buttonTxt:ISRIL.l('TryAgain'); if (typeof a.onclk == 'string') { this.bip('ErrorBtn').setAttribute('oncommand', a.onclk); } else { this.bip('ErrorBtn').onclick = a.onclk; } this.bip('ErrorCancel').hidden = a.noCancel; if (!a.noCancel) { a.onCanel = a.onCancel!=null?a.onCancel:function() { ISRILxul.ListErrorSet(false); }; if (typeof a.onCancel == 'string') { this.bip('ErrorCancel').setAttribute('oncommand', a.onCancel); } else { this.bip('ErrorCancel').onclick = a.onclk; } } this.ErrorOnBtn(false); } else { ISRILglobals.listShowErrorOnOpen = a; this.ErrorOnBtn(true); } } else { this.ShowList(); this.bip('Error').hidden = true; this.ErrorOnBtn(false); } }, ErrorOnBtn : function(show) { if (this.window.ISRILxul.ListBtn) { var cl = ' isRitL-Warn'; if (show && !this.window.ISRILxul.ListBtn.className.match(cl)) { this.window.ISRILxul.ListBtn.className += cl; } else { this.window.ISRILxul.ListBtn.className = this.window.ISRILxul.ListBtn.className.replace(cl, ''); ISRILglobals.listShowErrorOnOpen = false; } } }, // --- // MarkAsReadItem : function(id, chkmrk) { row = ISRILxul.bi(ISRILxul.dPrefix+'Item_'+id); if (!row.className.match(' isRitL-dim') ) { ISRIL.listDrops[id] = true; row.className += ' isRitL-dim'; chkmrk.setAttribute('tooltiptext', ISRIL.l('MarkAsReadCancel')); } else { ISRIL.listDrops[id] = false; row.className = row.className.replace(' isRitL-dim', ''); chkmrk.setAttribute('tooltiptext', ISRIL.l('MarkAsRead')); } if (ISRILxul.wType=='sidebar') { clearTimeout(ISRILxul.mrTO); ISRILxul.mrTO = setTimeout('ISRILxul.RunListDrops(true);', ISRILxul.sidebarMarkWait); } }, PageMove : function(n) { if (n == 0) { ISRILxul.curPage = ISRILxul.Page.selectedIndex + 1; } else { ISRILxul.curPage += n; totalpages = ISRILxul.TotalPages(); // -- Cases -- // if (ISRILxul.curPage < 1) { ISRILxul.curPage = 1; } if (ISRILxul.curPage > totalpages) { ISRILxul.curPage = totalpages; } } ISRILxul.Page.selectedIndex = ISRILxul.curPage-1; ISRILxul.FillList(true); }, TotalPages : function() { return Math.ceil(ISRILxul.totalList/ISRILxul.PerPage()); }, // --- // SetClickToSaveStatusBar : function(status) { ISRILprefs.setPref('clicktosaveinbar', status); ISRILxul.UseClickToSaveStatusBar(); }, UseClickToSaveStatusBar : function() { if ( ISRILxul.bip('ClickToSaveButton') ) { ISRILxul.bip('ClickToSaveButton').hidden = ((!ISRILprefs.prefB('clicktosaveinbar'))?(true):(false)); } }, // --- // OpenOffline : function() { ISRILxul.window.openDialog("chrome://isreaditlater/content/offline.xul", "", "chrome,titlebar,toolbar,centerscreen,modal"); }, // --- // OpenOptions : function(tab) { ISRILxul.window.openDialog("chrome://isreaditlater/content/options.xul", "", "chrome,titlebar,toolbar,centerscreen,modal", tab); }, // --- // OpenAnywhere : function() { if ( ISRILprefs.prefB('feed') && ISRILprefs.prefB('sync') && !ISRILprefs.prefB('online-access-prompt')) { ISRIL.online('unread'); } else { ISRILxul.window.openDialog("chrome://isreaditlater/content/anywhere.xul", "", "chrome,titlebar,toolbar,centerscreen,modal"); } }, // -- // NotSavedOffline : function() { msg = ISRIL.l('NotSavedOffline'); name = 'NotSavedOffline'; icon = 'chrome://isreaditlater/skin/offline16.png'; buttons = [{ label: ISRIL.l('Hide'), popup: null, callback: ISRIL.RemoveNotify, }]; ISRIL.GetNotify(name, msg, icon, buttons); }, // -- // maxPageN : function(lt) { lt = (!lt) ? ISRILprefs.pref('list-view') : lt; var rowHeight = (lt == 'normal') ? 41 : 18; var maxRows = Math.floor( screen.height * 0.5 / rowHeight ); return (maxRows > 0) ? maxRows : ISRILprefs.pref('list-page') * 1; }, // -- // recentWindow : function() { return Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser"); }, getSidebarWidth : function (w) { return window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow).document.getElementById("sidebar-box").width; }, setSidebarWidth : function (w) { window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow).document.getElementById("sidebar-box").width=w; }, // --- // fillSelect : function(obj, min, max, selected) { selected = selected?selected-min:0; obj.removeAllItems(); for(i=min; i<=max; i++) { obj.insertItemAt(i - 1, i, i); } obj.setAttribute('min', min); obj.selectedIndex = (selected > max - 1) ? (max - 1) : selected; }, // --- // createNode : function (ty, attributes) { node = document.createElement(ty); for(ik in attributes) { switch(ik) { case('class'): node.className = attributes[ik]; break; case('style'): if (typeof attributes[ik] == 'string') { node.setAttribute('style', attributes[ik]); } else { its = attributes[ik].split(';'); for(i=0; i<its.length; i++) { parts = its[i].split(':'); node.style[parts[0]] = parts[1]; } } break; case('innerHTML'): node.innerHTML = attributes[ik]; break; case('onclick'): if (typeof attributes[ik] == 'string') { node.setAttribute('onclick', attributes[ik]); } else { node.onclick = attributes[ik] } default: node.setAttribute(ik, attributes[ik]); } } return node; }, test : function() { var tabs = ISRILxul.bi('content').mTabs; for (i in tabs) { //doc = tabs[i].ownerDocument; for(c in tabs[i].childNodes) { ISRIL.d(tabs[i].childNodes[c]); } //element = doc.getAnonymousElementByAttribute(tabs[i], "anonid", "close-button"); } }, removeNode : function(node) { if (node) { return node.parentNode.removeChild(node); } }, } var ISRILxul = new ISRILxul();